import React, { useState } from 'react'

export default function App() {
  /* let sum = 0
  for (let i = 0; i < 1000; i++) {
    sum += i
  } */
  const [count, setCount] = useState(() => {
    let sum = 0
    for (let i = 0; i < 1000; i++) {
      sum += i
    }
    return sum
  })
  const handleClick = () => {
    setCount(count + 1)
  }
  return (
    <div>
      <h3>计数器：{count}</h3>
      <button onClick={handleClick}>+1</button>
    </div>
  )
}
